package com.da.javatest.niuke.jianzhi;

/**
 * @author chenlida
 * @date 2020/10/28 10:22
 * https://www.nowcoder.com/practice/57d85990ba5b440ab888fc72b0751bf8?
 * tpId=13&tags=&title=&diffculty=0&judgeStatus=0&rp=1
 */
public class C67Solution {
    public static int cutRope(int target) {
        int max = target;
        for (int i = 2; i < target / 2; i++) {
            int j = target / i;
            int k = target % i;
            int temp;
            if (k == 0) {
                temp = (int)Math.pow(i, j);
            } else if (k == 1) {
                temp = (int)Math.pow(i, j - 1) * (i + k);
            } else {
                temp = (int)Math.pow(i, j) * k;
            }
            if (temp > max) {
                max = temp;
            }
        }
        return max;
    }

    public static void main(String[] args) {
        System.out.println(cutRope(15));
    }
}
